<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        body {
            margin: 0;
        }
        .box {
            width: 800px;
            /* height: 450px; */
            font-size: 0;
        }

        ul {
            display: flex;
            justify-content: space-between;
            width: 100px;

        }

        ul li {
            width: 20px;
            height: 20px;
            cursor: pointer;
            margin-bottom: 10px;
            font-size: 25px;
        }

        .selected {
            list-style:circle;
        }

        .foot {
            background-image: linear-gradient(to top, rgb(30, 39, 79) 0px, rgb(30, 39, 79) 80px, transparent 100px);
            font-size: 20px;
            color: white;
            height: 100px;
            position: relative;
            bottom: 20px;
        }

        .oneline {
            display: flex;
            justify-content: space-between;
        }

        .btn {
            margin-right: 20px;
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="img/1.avif" alt="轮播图">

        <div class="foot">
            <div class="desc">进口车车机有多离谱？果然洋相还得洋人出啊</div>
            <div class="oneline">
                <ul>
                    <li class="selected"></li>
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
    
                <div class="btn">
                    <button class="btnleft"><</button>
                    <button class="btnright">></button>
                </div>
            </div>
            
        </div>
    </div>

<script>
    descArr = ["进口车车机有多离谱？果然洋相还得洋人出啊", "要变强，强到他人无可指摘！", "太好了是蛋糕王，我们有救了！", "正在直播上海Major：FaZe vs FURIA！", "分手后还能继续做朋友吗？"]

    let imgId = 0
    let img = document.querySelector("img")
    let desc = document.querySelector(".desc")
    let liarr = document.querySelectorAll("li")
    console.log(liarr)

    function do_switch(i) {
        imgId = (imgId + i + 5) % 5
        img.src = `img/${imgId + 1}.avif`
        desc.innerHTML = descArr[imgId]
        
        document.querySelector(".selected").classList.remove("selected")
        document.querySelector(`li:nth-child(${imgId + 1})`).classList.add("selected")
    }
    
    setInterval(function() {
        do_switch(1)
    }, 3000)

    let btnleft = document.querySelector(".btnleft")
    let btnright = document.querySelector(".btnright")

    btnleft.addEventListener("click", function() {
        do_switch(-1);
    })

    btnright.addEventListener("click", function() {
        do_switch(1)
    })

</script>
</body>
</html>